From db59dbc46e0312a38978d22c6bd72b554a2f1c91 Mon Sep 17 00:00:00 2001 From: Wei Liu Date: Sat, 2 Jul 2016 12:35:30 +0100 Subject: [PATCH] libxl/netbsd: check num_exec in hotplug function MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This basically replicates the same logic in libxl_linux.c but with one change -- only test num_exec == 0 in nic hotplug case because NetBSD let QEMU call a script itself. Without this patch libxl will loop indefinitely trying to execute hotplug script. Reported-by: John Nemeth Signed-off-by: Wei Liu Acked-by: Roger Pau Monné --- tools/libxl/libxl_netbsd.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tools/libxl/libxl_netbsd.c b/tools/libxl/libxl_netbsd.c index 096c0578fc..a79b8aae2b 100644 --- a/tools/libxl/libxl_netbsd.c +++ b/tools/libxl/libxl_netbsd.c @@ -68,7 +68,28 @@ int libxl__get_hotplug_script_info(libxl__gc *gc, libxl__device *dev, switch (dev->backend_kind) { case LIBXL__DEVICE_KIND_VBD: + if (num_exec != 0) { + LOG(DEBUG, "num_exec %d, not running hotplug scripts", num_exec); + rc = 0; + goto out; + } + rc = libxl__hotplug(gc, dev, args, action); + if (!rc) rc = 1; + break; case LIBXL__DEVICE_KIND_VIF: + /* + * If domain has a stubdom we don't have to execute hotplug scripts + * for emulated interfaces + * + * NetBSD let QEMU call a script to plug emulated nic, so + * only test if num_exec == 0 in that case. + */ + if ((num_exec != 0) || + (libxl_get_stubdom_id(CTX, dev->domid) && num_exec)) { + LOG(DEBUG, "num_exec %d, not running hotplug scripts", num_exec); + rc = 0; + goto out; + } rc = libxl__hotplug(gc, dev, args, action); if (!rc) rc = 1; break; -- 2.30.2